FACTORY_FLG="../factory/run.sh.log"
DEF_PARAM="../app_driver/def_param.rpc"
ROUTE_DIR="../app_sav/route"
AUTH_TXT="../app_sav/route/auth.txt"
ROUTE_TXT="../app_sav/route/route.txt"

# Add executable permissions to files
chmod 755 -R ../app_driver

# load drivers
cd ./driver/ko
./load3559av100_multicore -i -sensor0 imx477 -sensor1 imx477
cd -

# add lib to LD_LIBRARY_PATH
LD_LIBRARY_PATH=./lib
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH

# web stuff
if [ ! -e ${ROUTE_DIR} ] || [ ! -e ${AUTH_TXT} ] || [ ! -e ${ROUTE_TXT} ]; then
    cp -rfd ./web/route ../app_sav
fi

#daemon.out start
./bins/daemon.out -f ./scripts/process_run.sh &

#loading default parameters
if [ -f ${DEF_PARAM} ];then
    chmod 744 -R ${DEF_PARAM}
    if [ -f ${FACTORY_FLG} ];then
        ./bins/rpc_load.out  -s 10 -d 500 -f ./profile/def_param.rpc -p mpsoc_mq_trans & 
        rm ${FACTORY_FLG} -f
        echo "Factory execution, loading default parameters !"
    fi
fi

#end